package com.example.diffservice.algorithm.entity;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.ArrayList;
import java.util.List;

/**
 * @author DestinyCc
 * @date 2022/3/28
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class Meta {
    private String author;

    private String commitHash;

    private List<String> parents;

    private List<CommitFile> files;

    private List<String> actions;

    private String outputDir;

    public void addParentCommit(String commitId){
        if (this.parents == null){
            this.parents = new ArrayList<>();
        }
        this.parents.add(commitId);
    }

    public void addAction(String action){
        if (this.actions == null){
            this.actions = new ArrayList<>();
        }
        this.actions.add(action);
    }

    public void addFile(CommitFile file){
        if (this.files == null){
            this.files = new ArrayList<>();
        }
        this.files.add(file);
    }

}
